package com.legendshop.openportal.sdk.model.constants;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;
import java.util.Arrays;

/**
 * @Description: 商品库存状态枚举
 * @Author lwj
 * @data 2024/7/25
 **/

@Getter
public enum ProdStockStateEnum {

    INSTOCK_IMMEDIATE_SHIPPING(new BigDecimal("33"), "有货 现货-下单立即发货"),

    INTRANSIT_INNER_ALLOCATION(new BigDecimal("39"), "有货 在途-正在内部配货，预计2~6天到达本仓库"),

    STOCK_AVAILABLE(new BigDecimal("40"), "有货 可配货-下单后从有货仓库配货"),

    PREORDER(new BigDecimal("36"), "预订"),

    OUTOFSTOCK(new BigDecimal("34"), "无货"),

    OUTOFSTOCK_PREORDER_AVAILABLE(new BigDecimal("99"), "无货开预定");

    private final BigDecimal statusCode;
    private final String description;

    ProdStockStateEnum(BigDecimal statusCode, String description) {
        this.statusCode = statusCode;
        this.description = description;
    }

    public BigDecimal getStatusCode() {
        return statusCode;
    }

    public String getDescription() {
        return description;
    }

    public String findDescByCode(BigDecimal statusCode) {
        ProdStockStateEnum prodStockStateEnum = Arrays.stream(ProdStockStateEnum.values()).filter((item) -> item.getStatusCode().compareTo(statusCode) == 0).findFirst().orElse(null);
        if (prodStockStateEnum == null) {
            return null;
        }
        return prodStockStateEnum.getDescription();

    }
}
